<template>
  <el-table :data="appointmentList" style="width: 100%">
    <el-table-column label="用户名" prop="username"></el-table-column>
    <el-table-column label="年龄" prop="age"></el-table-column>
    <el-table-column label="性别" prop="gender"></el-table-column>
    <el-table-column label="预约时间" prop="appointmentTime"></el-table-column>
  </el-table>
</template>

<script setup>
import { onMounted, ref } from 'vue';
import { consultantAppointmentList } from '@/api/appointment';
import { useUserInfoStore } from '@/stores/userInfo';

const appointmentList = ref([]);
const userInfoStore = useUserInfoStore();

const getAppointmentList = () => {
  const consultantId = userInfoStore.userInfo.id;
  if (!consultantId) {
    console.error('未获取到咨询师ID');
    appointmentList.value = [];
    return;
  }
  consultantAppointmentList({ consultantId }).then(res => {
    appointmentList.value = res;
  });
};

onMounted(() => {
  getAppointmentList();
});
</script>

<style scoped>
/* 样式 */
</style>